home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
CIncludesTool
/
modified version
/
put in scripts folder
/
MWCIncludesTool
< prev
next >
Wrap
Text File
|
1994-02-27
|
10KB
|
374 lines
# Script For CIncludes Tool - by John Jeppson
# modified for use with Metrowerks
Set Exit 0
Set param 0
Set toolStatus 0
If {#} == 2
If ("{1}" == "-f") || ("{1}" == "-F")
Set param 2
Else If ("{1}" == "-i") || ("{1}" == "-I")
Set param 3
Else If ("{1}" == "-d") || ("{1}" == "-D") # Daniel Grassi
Set param 4
End
Else
If {#} == 1
If ("{1}" == "-m") || ("{1}" == "-M")
Set param 1
End
End
End
If {param} == 0
Alert "MWCIncludesTool - Usage : MWCIncludesTool [-f -m -i -d] SrchString ∂n ∂
-f Locates SrchString∂n ∂
-m Rebuilds the CIncludes identifier dictionary∂n ∂
-i Reformats ∂"#include∂" statements in selection∂n ∂
-d Displays the file declaring SrchString"
Else If {param} == 1
## Find §:/∞/ "{Active}"
## Find §Δ "{Active}"
## Echo
If ("{CIncludesCompiler}" == 'AppleCFront')
Set j "`Quote "{CIncludes}"`≈.h"
Begin
Set SrchList ""
Set j "`Quote "{CIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList "`Quote "{CIncludes}"`≈.h"
Else
Set SrchList ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{CIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
If ({MACPlusIncludes} != "")
Begin
Set SrchList2 ""
Set j "`Quote "{MACPlusIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList2 "`Quote "{MaCPLusIncludes}"`≈.h"
Else
Set SrchList2 ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{MACPlusIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList2 "{SrchList2} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
Unset SrchList2
Else
CIncludesCode -m `Files -fr {SrchList}`
End # If
Else
If ("{CIncludesCompiler}" == 'SymantecC++')
Begin
Set SrchList ""
Set j "`Quote "{SCIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList "`Quote "{SCIncludes}"`≈.h"
Else
Set SrchList ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{SCIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
If ({MASCPlusIncludes} != "")
Begin
Set SrchList2 ""
Set j "`Quote "{MASCPlusIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList2 "`Quote "{MASCPlusIncludes}"`≈.h"
Else
Set SrchList2 ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{MASCPlusIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList2 "{SrchList2} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
Unset SrchList2
Else
CIncludesCode -m `Files -fr {SrchList}`
End # If
Else
If ("{CIncludesCompiler}" == 'MetrowerksC++')
Begin
Set SrchList ""
Set j "`Quote "{MWIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList "`Quote "{MWIncludes}"`≈.h"
Else
Set SrchList ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{MWIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
If ({MAMCPlusIncludes} != "")
Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
Begin
Set SrchList2 ""
Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
If ("`Exists -f {j}`" != "")
Set SrchList2 "`Quote "{MAMCPlusIncludes}"`≈.h"
Else
Set SrchList2 ""
End # If Exists
End ≥ Dev:Null
For j in `Files -fr -d -r -o "{MAMCPlusIncludes}"`
If ("`Exists -f "{j}"≈.h`" != "")
Set j "`Quote "{j}"`"
Set SrchList2 "{SrchList2} {j}≈.h"
End # If Exists
End ∑ Dev:Null # For j
CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
Unset SrchList2
Else
CIncludesCode -m `Files -fr {SrchList}`
End # If
End # If
End # If
End # If
Unset SrchList
Set toolStatus "{Status}"
Beep 2C,20,128
Else If {param} == 2
## Mark -y § x162534 "{Active}"
Set str "{2}"
CIncludesCode -v "{str}"
Set toolStatus "{Status}"
If {toolStatus} == 0
## Find • "{Active}"
## Find Δ/#include/ "{Active}" # Daniel Grassi
## CIncludesCode -f "{str}"
## Set toolStatus "{Status}"
## replacement (different functionality) from above
Set counter 1
For i in `CIncludesCode -d "{str}"`
If {counter} == 1
Echo "∂#include ∂<{i}∂>" ∑∑ Dev:StdErr
Beep 1C
Set counter 2
End # If {counter}
End # For i
End # If {ToolStatus}
## Find x162534 "{Active}"
## Unmark x162534 "{Active}"
Else If {param} == 3
## CIncludesCode -i "{Active}.§"
## Set toolStatus "{Status}"
Alert "{0} :∂n∂noption -i (reformating selected include statements) is not supported in Metrowerks."
Else If {param} == 4 # Daniel Grassi
Set str "{2}"
CIncludesCode -v "{str}"
Set toolStatus "{Status}"
If {toolStatus} == 0
Set counter 1
For i in `CIncludesCode -d "{str}"`
If {counter} == 1
If ("{CIncludesCompiler}" == 'AppleCFront')
Set SrchList "`Quote "{CIncludes}{i}"`"
For j in `Files -fr -d -r "{CIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End ∑ Dev:Null # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Set SrchList "`Quote "{MACPlusIncludes}{i}"`"
For j in `Files -fr -d -r "{MACPlusIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End ∑ Dev:Null # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Alert "Unable to open the header file {i}"
End # If {Status}
End # If {Status}
Else
If ("{CIncludesCompiler}" == 'SymantecC++')
Set SrchList "`Quote "{SCIncludes}{i}"`"
For j in `Files -fr -d -r "{SCIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End ∑ Dev:Null # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Set SrchList "`Quote "{MASCPlusIncludes}{i}"`"
For j in `Files -fr -d -r "{MASCPlusIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End ∑ Dev:Null # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Alert "Unable to open the header file {i}"
End # If {Status}
End # If {Status}
Else
If ("{CIncludesCompiler}" == 'MetrowerksC++')
Set SrchList "`Quote "{MWIncludes}{i}"`"
For j in `Files -fr -d -r "{MWIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Set SrchList "`Quote "{MAMCPlusIncludes}{i}"`"
For j in `Files -fr -d -r "{MAMCPlusIncludes}"`
Set j "`Quote "{j}"`"
Set SrchList "{SrchList} {j}{i}"
End ∑ Dev:Null # For j
For j in {SrchList}
## Open -r "{j}" ∑∑ Dev:Null
Set j "`Quote "{j}"`"
If ("`Exists -f {j}`" != "")
MWFile {j} ∑∑ Dev:Null
If ({Status} == 0)
Set FoundIt 1
Set HeaderName "{j}"
Break
End # If {Status}
End # If Exists
End ∑ Dev:Null # For j
Unset SrchList
If ({FoundIt} == 0)
Alert "Unable to open the header file {i}"
End # If {Status}
End # If {Status}
End # If
End # If
End # If
Set counter 2
Else
## Find •!{i} "{Active}"
## Find \{str}\ "{Active}" ∑∑ Dev:Null
Set HeaderName "`Quote {HeaderName}`"
Set LineNo "`FilePosToLine {HeaderName} "{i}"`"
RMetrowerks line "{LineNo}"
End
End
If ("{i}" == "")
Set toolStatus 4 # new - signal that no identifiers were found
Else
Set toolStatus "{Status}"
End # If {i}
End
End
If {toolStatus}
If {toolStatus} == '1'
Alert 'Bad parameters to "MWCIncludesTool"' # won't occur here
Else If {toolStatus} == '2'
Alert 'Invalid Identifier!'
Else If {toolStatus} == '3'
If ({param} == 2) || (param} == 3)
Alert 'Unable to load database resource!'
Else
Alert 'Out of memory error!'
End
Else If {toolStatus} == '4'
Alert 'Identifier not found in CIncludes!'
Else
Alert "Unknown CIncludes error return value ({toolStatus})."
End
End
# end of MWCIncludesTool